Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function AddOrUpdate ( _
key As TKey, _
addValueFactory As Func(Of TKey, TValue), _
updateValueFactory As Func(Of TKey, TValue, TValue) _
) As TValue |
C# |
---|
public TValue AddOrUpdate(
TKey key,
Func<TKey, TValue> addValueFactory,
Func<TKey, TValue, TValue> updateValueFactory
) |
Parameters
- key
- Type: TKey
The key to be added or whose value should be updated
- addValueFactory
- Type: System..::.Func<(Of <(TKey, TValue>)>)
The function used to generate a value for an absent key
- updateValueFactory
- Type: System..::.Func<(Of <(TKey, TValue, TValue>)>)
The function used to generate a new value for an existing key
based on the key's existing value
Return Value
The new value for the key. This will be either be the result of addValueFactory (if the key was
absent) or the result of updateValueFactory (if the key was present).
Exceptions
Exception | Condition |
---|
System..::.ArgumentNullException | key is a null reference
(Nothing in Visual Basic). |
System..::.ArgumentNullException | addValueFactory is a null reference
(Nothing in Visual Basic). |
System..::.ArgumentNullException | updateValueFactory is a null reference
(Nothing in Visual Basic). |
System..::.OverflowException | The dictionary contains too many
elements. |
See Also